package com.sasu.university_data.service.impl;

import com.sasu.university_data.entity.CollegeInfo;
import com.sasu.university_data.mapper.CollegeInfoMapper;
import com.sasu.university_data.service.CollegeInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("collegeService")
public class CollegeInfoServiceImpl implements CollegeInfoService {

    @Resource
    private CollegeInfoMapper collegeInfoMapper;

    @Override
    public CollegeInfo selectByName ( String schoolName ) {
        return collegeInfoMapper.selectByName(schoolName);
    }

    @Override
    public CollegeInfo selectImgsByName ( String name ) {
        return collegeInfoMapper.selectImgsByName(name);
    }

    @Override
    public CollegeInfo queryById ( Integer id ) {
        return null;
    }

    @Override
    public long count (String name) {
        return collegeInfoMapper.count(name);
    }

    @Override
    public List<CollegeInfo> selectByPage ( String name, Integer page, Integer pageSize ) {
        if(page<=1) {
            page = 1;
        }
        if(pageSize<=0) {
            pageSize = 10;
        }
        return collegeInfoMapper.selectByPage(name,(page - 1) * pageSize, pageSize);
    }

    @Override
    public boolean insert ( CollegeInfo collegeInfo ) {
        return collegeInfoMapper.insert(collegeInfo)>0;
    }

    @Override
    public boolean update ( CollegeInfo collegeInfo ) {
        return collegeInfoMapper.update(collegeInfo)>0;
    }

    @Override
    public boolean deleteById ( Integer id ) {
        return collegeInfoMapper.deleteById(id)>0;
    }

    @Override
    public boolean deleteByIds ( int[] Ids ) {
        return collegeInfoMapper.deleteByIds(Ids)>0;
    }
}
